<template>
	<view>
		<!-- 地址 -->
		<navigator url="/pages/address/address?source=1" class="address-section">
			<view class="order-content">
				<text class="iconfont icondizhi"></text>
				<view v-if="selectedAddress.id == null" class="cen">
					您还没有默认收货地址哦，点击选择收货地址
				</view>
				<view v-else class="cen">
					<view class="top">
						<text class="name">{{selectedAddress.realName}}</text>
						<text class="mobile">{{selectedAddress.phone}}</text>
					</view>
					<text class="address">{{selectedAddress.addressAlias}} {{selectedAddress.address}}</text>
				</view>
				<text class="iconfont iconxiangyou icon-you"></text>
			</view>
			<image class="a-bg" src=""></image>
		</navigator>

		<view class="goods-section">
			<view v-for="(shopSkus, shopIndex) in shopSkuList" :key="shopIndex">
				<view class="g-header b-b">
					<image class="logo" :src="localFileStorage ? frontBaseUrl + shopSkus.shopLogo : shopSkus.shopLogo"></image>
					<text class="name">{{shopSkus.shopTitle}}</text>
				</view>
				<!-- 商品列表 -->
				<view class="g-item" v-for="(item, skuIndex) in shopSkus.skuList" :key="skuIndex">
					<image :src="localFileStorage ? frontBaseUrl + item.goodsSkuPicUrl : item.goodsSkuPicUrl"></image>
					<view class="right">
						<text class="title clamp">{{item.title}}</text>
						<text class="spec">{{item.skuSpecStr}}</text>
						<view class="price-box">
							<text class="price">￥{{item.salePrice}}</text>
							<text style="color: #fa436a; font-size: 26upx;" v-if="item.overStoreCount">库存不足</text>
							<!-- #ifdef MP || APP-PLUS -->
							<uni-number-box
								class="number-box"
								:min="1" 
								:max="item.storeCount"
								:value="item.quantity"
								:index="shopIndex"
								:index_="skuIndex"
								@eventChange="numberChange"
							></uni-number-box>
							<!-- #endif -->
							<!-- #ifdef H5 -->
							<uni-number-box
								class="number-box"
								:min="1" 
								:max="item.storeCount"
								v-model="item.quantity"
								:index="shopIndex"
								:index_="skuIndex"
								:disabled="true"
								@eventChange="numberChange"
							></uni-number-box>
							<!-- #endif -->
						</view>
					</view>
				</view>
				<view class="yt-list">
					<view class="yt-list-cell b-b">
						<text class="cell-tit clamp">订单备注</text>
						<input class="desc" type="text" v-model="shopSkus.remark" placeholder="请填写备注信息" placeholder-class="placeholder" />
					</view>
					
					<view class="yt-list-cell b-b" @click="toggleDeliveryMask('show')">
						<text class="cell-tit clamp">运送方式</text>
						<text class="cell-tip active">
							普通快递
						</text>
						<text v-if="multipleDeliveryType" class="cell-more iconfont iconxiangyou"></text>
					</view>
					
					<view class="yt-list-cell b-b" @click="toggleCouponMask('show')">
						<view class="cell-icon">
							券
						</view>
						<text class="cell-tit clamp">优惠券</text>
						<text class="cell-tip active">
							选择优惠券
						</text>
						<text class="cell-more iconfont iconxiangyou"></text>
					</view>
					<view class="yt-list-cell b-b">
						<view class="cell-icon hb">
							减
						</view>
						<text class="cell-tit clamp">商家促销</text>
						<text class="cell-tip disabled">暂无可用优惠</text>
					</view>
					
					<view class="yt-list-cell b-b">
						<text class="cell-tit clamp">商品金额</text>
						<text class="cell-tip">￥{{totalPay}}</text>
					</view>
					<view class="yt-list-cell b-b">
						<text class="cell-tit clamp">优惠金额</text>
						<text class="cell-tip red">-￥{{discount}}</text>
					</view>
					<view class="yt-list-cell b-b">
						<text class="cell-tit clamp">运费</text>
						<text class="cell-tip">{{expressFee == 0 ? '免运费' : '¥ ' + expressFee}}</text>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 底部 -->
		<view class="footer">
			<view class="price-content">
				<text>实付款</text>
				<text class="price-tip">￥</text>
				<text class="price">{{actualPay}}</text>
			</view>
			<button class="submit" @click="submitOrder" :disabled="isSubmitOrder">提交订单</button>
		</view>
		
		<!-- 优惠券面板 -->
		<view class="mask" :class="couponMaskState===0 ? 'none' : couponMaskState===1 ? 'show' : ''" @click="toggleCouponMask">
			<view class="mask-content" @click.stop.prevent="stopPrevent">
				<!-- 优惠券页面，仿mt -->
				<view class="coupon-item" v-for="(item,index) in couponList" :key="index">
					<view class="con">
						<view class="left">
							<text class="title">{{item.title}}</text>
							<text class="time">有效期至2019-06-30</text>
						</view>
						<view class="right">
							<text class="price">{{item.price}}</text>
							<text>满30可用</text>
						</view>
						
						<view class="circle l"></view>
						<view class="circle r"></view>
					</view>
					<text class="tips">限新用户使用</text>
				</view>
			</view>
		</view>
		
		<!-- 运送方式面板 -->
		<view class="mask" :class="deliveryMaskState===0 ? 'none' : deliveryMaskState===1 ? 'show' : ''" @click="toggleDeliveryMask">
			<view class="mask-content" @click.stop.prevent="stopPrevent">
				<view class="delivery-section">
					<view :class="{active : deliveryType === 0}" @click="changeDeliveryType(0)">普通快递</view>
					<view :class="{active : deliveryType === 1}" @click="changeDeliveryType(1)">线下门店自提</view>
					<view :class="{active : deliveryType === 2}" @click="changeDeliveryType(2)">线下指定门店自提</view>
					<text @click="chooseDelivery">确定</text>
				</view>
				<view class="delivery-desc" v-if="deliveryType === 0">
					<view style="text-align: center; font-weight: bold;">运送说明</view>
					<view><text style="font-weight: bold;">普通快递：</text>如圆通，申通，中通，韵达等</view>
					<view><text style="font-weight: bold;">线下门店自提：</text>您可查看支持自提的线下门店，下单后可到任意一家门店提取商品</view>
					<view><text style="font-weight: bold;">线下指定门店自提：</text>您可查看支持自提的线下门店，下单时选择一家门店，下单后到该门店提取商品</view>
				</view>
				<view v-if="deliveryType === 1" class="coupon-item" v-for="(item,index) in couponList" :key="index">
					<view class="con">
						<view class="left">
							<text class="title">{{item.title}}</text>
							<text class="time">有效期至2019-06-30</text>
						</view>
						<view class="right">
							<text class="price">{{item.price}}</text>
							<text>满30可用</text>
						</view>
						
						<view class="circle l"></view>
						<view class="circle r"></view>
					</view>
					<text class="tips">限新用户使用</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import uniNumberBox from '@/components/uni-number-box.vue'
	import {doPostJson, showInfoToast, REFRESH_PRODUCT, REFRESH_CART, FRONT_BASE_URL, LOCAL_FILE_STORAGE,
	invalidToken, toLogin} from '@/common/util.js'
	import * as ResponseStatus from '@/common/response-status.js'
	export default {
		components: {
			uniNumberBox
		},
		data() {
			return {
				skuIds: null,
				quantity: null,
				agentRole: 'none',
				cartData: null,
				selectedAddress: {},
				shopSkuList: [],
				totalPay: 0,
				discount: 0,
				actualPay: 0,
				expressFee: 0,
				couponMaskState: 0, //优惠券面板显示状态
				deliveryMaskState: 0,
				deliveryType: 0, // 0 普通快递， 1 线下门店自提 2 线下指定门店自提
				multipleDeliveryType: false,
				choosedDeliveryType: 0, // 默认的运送方式，普通快递
				couponList: [
					{
						title: '新用户专享优惠券',
						price: 5,
					},
					{
						title: '庆五一发一波优惠券',
						price: 10,
					},
					{
						title: '优惠券优惠券优惠券优惠券',
						price: 15,
					}
				],
				frontBaseUrl: FRONT_BASE_URL,
				localFileStorage: LOCAL_FILE_STORAGE,
				isSubmitOrder: false
			}
		},
		onLoad(option){
			this.skuIds = option.skuIds
			this.quantity = option.quantity
			if (option.agentRole) {
				this.agentRole = option.agentRole
			}
			let cartData = option.cartData
			if (cartData) {
				this.cartData = JSON.parse(cartData)
			}
			this.loadDefaultAddress()
			// 如果有skuIds和quantity，表示从商品详情直接下单
			this.loadGoodsSkuFromProductDetail()
			// 如果有cartData，表示从购物车中下单，包含有sku的编号和数量
			this.loadGoodsSkuFromCart()
		},
		methods: {
			loadDefaultAddress() {
				doPostJson('/shipping-address/user/pager-cond', {
					pageNo: 1,
					pageSize: 1,
					isDefault: 1,
					sortColumn: 'updateTime',
					sortOrder: 'desc'
				}, {}, true).then(response => {
					let [error, res] = response
					if (res.data.code === ResponseStatus.OK) {
						if (res.data.data.rows.length === 1) {
							this.selectedAddress = res.data.data.rows[0]
						}
					} else if (res.data.code === ResponseStatus.AUTHENTICATION_TOKEN_ERROR) {
						invalidToken()
						setTimeout(() => {
							toLogin()
						}, 3000)
					}
				}).catch(error => {
					console.log(error)
				})
			},
			loadGoodsSkuFromProductDetail() {
				if (this.skuIds && this.quantity) {
					doPostJson('/goods-sku-attr-val/any/goods-goods-sku-attr', {
						"goodsSkuId": this.skuIds,
						"sortColumn": "goodsSkuId",
						"sortOrder":"asc"
					}, {}).then(response => {
						let [error, res] = response
						if (res.data.code === ResponseStatus.OK) {
							let goodsInfo = res.data.data
							let theSkuInfo = this.getSkuInfo(goodsInfo, this.quantity)
							let shopSkus = {}
							shopSkus.shopId = theSkuInfo.shopId
							shopSkus.shopLogo = theSkuInfo.shopLogo
							shopSkus.shopTitle = theSkuInfo.shopTitle
							shopSkus.skuList = [theSkuInfo]
							this.shopSkuList.push(shopSkus)
							this.calculateActualPay()
							// 后台计算总运费
							this.computeExpressFee()
						}
					}).catch(error => {
						console.log(error)
					})
				}
			},
			loadGoodsSkuFromCart() {
				if (this.cartData) {
					let skuIds = ''
					this.cartData.forEach((item, index) => {
						skuIds += item.goodsSkuId + ','
					})
					doPostJson('/goods-sku-attr-val/any/goods-goods-sku-attr/' + skuIds, {}, {}).then(response => {
						let [error, res] = response
						if (res.data.code === ResponseStatus.OK) {
							let goodsList = res.data.data
							if (goodsList.length > 0) {
								let list = []
								goodsList.forEach((item, index) => {
									list.push(this.getSkuInfo(item, 0))
								})
								this.calSkuQuantity(list)
								this.filterSkuListByShop(list)
								this.calculateActualPay()
							}
							uni.hideLoading()
						} 
					}).catch(error => {
						console.log(error)
					})
				}
			},
			getSkuInfo(goodsInfo, quantity) {
				let theSkuInfo = {}
				let goodsSku = goodsInfo.goodsSkuVOList[0]
				theSkuInfo.shopId = goodsInfo.goodsInfoShopId
				theSkuInfo.shopLogo = goodsInfo.goodsShopLogo
				theSkuInfo.shopTitle = goodsInfo.goodsShopTitle
				theSkuInfo.goosInfoId = goodsInfo.goodsInfoId
				theSkuInfo.goodsSkuId = goodsSku.goodsSkuId
				theSkuInfo.goodsSkuPicId = goodsSku.goodsSkuPicId
				theSkuInfo.goodsSkuPicUrl = goodsSku.goodsSkuPicUrl
				theSkuInfo.title = goodsSku.goodsSkuTitle
				theSkuInfo.salePrice = goodsSku.goodsSkuSalePrice
				theSkuInfo.storeCount = goodsSku.goodsSkuStockCount
				let skuSpecStr = ''
				goodsSku.goodsSkuAttrVOList.forEach((goodsSkuAttr, index) => {
					if (goodsSkuAttr.goodsCategoryAttributeIsAttrGroup === 1) {
						skuSpecStr += goodsSkuAttr.goodsAttributeValueAttrValue + ' '
					}
				})
				theSkuInfo.skuSpecStr = skuSpecStr
				theSkuInfo.quantity = quantity
				theSkuInfo.overStoreCount = false
				return theSkuInfo
			},
			// 获取每个sku的购买数量
			calSkuQuantity(shopSkuList) {
				shopSkuList.forEach((shopSkus, index) => {
					this.cartData.forEach((cartData, index) => {
						if (shopSkus.goodsSkuId === cartData.goodsSkuId) {
							shopSkus.id = cartData.id
							shopSkus.quantity = cartData.quantity
						}
					})
				})
			},
			// 对所有商品SKU列表进行过滤，把同一个店铺的商品SKU归类到同一个对象中
			filterSkuListByShop(goodsSkuList) {
				let shopIds = []
				goodsSkuList.forEach((item, index) => {
					if (shopIds.indexOf(item.shopId) < 0) {
						shopIds.push(item.shopId)
					}
				})
				shopIds.forEach((item, index) => {
					let shopSkus = {}
					shopSkus.skuList = []
					shopSkus.skuList = goodsSkuList.filter(goodsSku => goodsSku.shopId == item)
					shopSkus.shopId = shopSkus.skuList[0].shopId
					shopSkus.shopLogo = shopSkus.skuList[0].shopLogo
					shopSkus.shopTitle = shopSkus.skuList[0].shopTitle
					this.shopSkuList.push(shopSkus)
				})
				// 后台计算总运费
				this.computeExpressFee()
			},
			// 计算实付金额
			calculateActualPay() {
				this.totalPay = 0
				this.shopSkuList.forEach((shopSkus, index) => {
					shopSkus.skuList.forEach(sku => {
						this.totalPay += (sku.salePrice * sku.quantity)
					})
				})
				this.totalPay = this.totalPay.toFixed(2)
				let actualPay = this.totalPay - this.discount + parseInt(this.expressFee)
				this.actualPay = actualPay.toFixed(2)
				
			},
			/**
			 * 计算总运费
			 */
			computeExpressFee() {
				let province = ''
				if (this.selectedAddress.id) {
					// 有默认地址
					province = this.selectedAddress.province
				}
				let expressCompute = []
				this.shopSkuList.forEach(shopSkuItem => {
					shopSkuItem.skuList.forEach(item => {
						const goodsPrice = item.salePrice * item.quantity
						expressCompute.push({
							goodsId: item.goosInfoId,
							skuId: item.goodsSkuId,
							goodsCount: item.quantity,
							goodsPrice: goodsPrice,
							province: province
						})
					})
				})
				doPostJson('/goods-express/user/compute-express-fee', expressCompute, {}, true).then(response => {
					let [error, res] = response
					if (res.data.code === ResponseStatus.OK) {
						this.expressFee = res.data.data.toFixed(2)
						// 重新计算总价
						this.calculateActualPay()
					}
				})
			},
			// 保存订单并跳转到支付页面
			submitOrder(){
				if (!this.selectedAddress.id) {
					showInfoToast('请先选择收货地址')
					return
				}
				uni.showLoading({
					title:'提交订单...'
				})
				this.isSubmitOrder = true
				doPostJson('/goods-order/user/save/' + this.agentRole, this.getOrderInfoList(), {}, true).then(response => {
					uni.hideLoading()
					let [error, res] = response
					if (res.data.code === ResponseStatus.OK) {
						// 如果从商品中直接购买，则需要刷新商品信息
						if (this.skuIds) {
							uni.setStorageSync(REFRESH_PRODUCT, true)
						}
						if (this.cartData) {
							// 如果从购物车中结算，则需要删除购物车中结算的sku信息
							let cartIds = []
							this.cartData.forEach((item, index) => {
								cartIds.push(item.cartId)
							})
							doPostJson('/goods-cart/user/batch-remove', cartIds, {}, true).then(response => {
							}).catch(error => {
								console.log(error)
							})
							uni.setStorageSync(REFRESH_CART, true)
						}
						let orderIdAndNos = res.data.data['0']
						uni.redirectTo({
							url: `/pages/money/pay?orderIdAndNos=${orderIdAndNos}&totalPay=${this.actualPay}`
						})
						this.isSubmitOrder = false
					} else if (res.data.code === ResponseStatus.DATA_ERROR) {
						// sku库存不足
						this.shopSkuList.forEach((shopSkus, index) => {
							shopSkus.skuList.forEach(sku => {
								// 判断哪些sku库存不足
								if (res.data.data[sku.goodsSkuId] === 0) {
									// 此sku库存不足
									sku.overStoreCount = true
								}
							})
						})
						showInfoToast('部分商品库存不足，请修改购买数量后再下单')
						this.isSubmitOrder = false
					} else {
						showInfoToast(res.data.message)
					}
				}).catch(error => {
					console.log(error)
				})
			},
			getOrderInfoList() {
				let orderList = []
				this.shopSkuList.forEach(shopSkus => {
					let order = {}
					order.shopId = 0
					let orderItems = []
					let totalAmount = 0
					shopSkus.skuList.forEach(sku => {
						totalAmount += (sku.salePrice * sku.quantity)
						if (order.shopId === 0) {
							order.shopId = sku.shopId
						}
						console.log(sku)
						let orderItem = {
							shopId: sku.shopId,
							goodsId: sku.goosInfoId,
							goodsSkuId: sku.goodsSkuId,
							skuPicId: sku.goodsSkuPicId,
							skuPicUrl: sku.goodsSkuPicUrl,
							skuTitle: sku.title,
							skuInfo: sku.skuSpecStr,
							quantity: sku.quantity,
							payAmount: sku.salePrice * sku.quantity
						}
						orderItems.push(orderItem)
					})
					order.totalAmount = totalAmount.toFixed(2)
					order.discountAmount = 0
					order.expressFee = this.expressFee
					order.payAmount = (order.totalAmount - this.discount + parseFloat(this.expressFee)).toFixed(2)
					order.platDiscountAmount = 0
					order.shopDiscountAmount = 0
					order.remark = shopSkus.remark
					order.addressId = this.selectedAddress.id
					order.deliverType = this.choosedDeliveryType === 0 ? '普通快递' : this.choosedDeliveryType === 1 ? '线下门店自提' : this.choosedDeliveryType === 2 ? '线下指定门店自提' : ''
					order.goodsOrderItemInVOList = orderItems 
					orderList.push(order)
				})
				return orderList
			},
			//显示优惠券面板
			toggleCouponMask(type){
				//showInfoToast('暂无可用优惠券')
				let timer = type === 'show' ? 10 : 300;
				let	state = type === 'show' ? 1 : 0;
				this.couponMaskState = 2;
				setTimeout(()=>{
					this.couponMaskState = state;
				}, timer)
			},
			//显示运送方式面板
			toggleDeliveryMask(type){
				if (!this.multipleDeliveryType) {
					return
				}
				//showInfoToast('暂无可用优惠券')
				let timer = type === 'show' ? 10 : 300;
				let	state = type === 'show' ? 1 : 0;
				this.deliveryMaskState = 2;
				setTimeout(()=>{
					this.deliveryMaskState = state;
				}, timer)
			},
			changeDeliveryType(type) {
				this.deliveryType = type
			},
			chooseDelivery() {
				this.toggleDeliveryMask()
				this.choosedDeliveryType = this.deliveryType
			},
			numberChange(data) {
				this.number = !data.number || data.number == 0 ? 1 : data.number
				this.shopSkuList[data.index].skuList[data.index_].quantity = this.number
				this.calculateActualPay()
				this.computeExpressFee()
			},
			stopPrevent(){}
		}
	}
</script>

<style lang="scss">
	@import '@/common/zywork-main.scss';
	page {
		background: $page-color-base;
		padding-bottom: 100upx;
	}

	.address-section {
		padding: 30upx 0;
		background: #fff;
		position: relative;

		.order-content {
			display: flex;
			align-items: center;
		}

		.icondizhi {
			flex-shrink: 0;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 90upx;
			color: #888;
			font-size: 44upx;
		}

		.cen {
			display: flex;
			flex-direction: column;
			flex: 1;
			font-size: 28upx;
			color: $font-color-dark;
		}

		.name {
			font-size: 34upx;
			margin-right: 24upx;
		}

		.address {
			margin-top: 16upx;
			margin-right: 20upx;
			color: $font-color-light;
		}

		.icon-you {
			font-size: 32upx;
			color: $font-color-light;
			margin-right: 30upx;
		}

		.a-bg {
			position: absolute;
			left: 0;
			bottom: 0;
			display: block;
			width: 100%;
			height: 5upx;
		}
	}

	.goods-section {
		margin-top: 16upx;
		background: #fff;
		padding-bottom: 1px;

		.g-header {
			display: flex;
			align-items: center;
			height: 84upx;
			padding: 0 30upx;
			position: relative;
		}

		.logo {
			display: block;
			width: 50upx;
			height: 50upx;
			border-radius: 100px;
		}

		.name {
			font-size: 30upx;
			color: $font-color-base;
			margin-left: 24upx;
		}

		.g-item {
			display: flex;
			margin: 20upx 30upx;

			image {
				flex-shrink: 0;
				display: block;
				width: 140upx;
				height: 140upx;
				border-radius: 4upx;
			}

			.right {
				flex: 1;
				padding-left: 24upx;
				overflow: hidden;
			}

			.title {
				font-size: 30upx;
				color: $font-color-dark;
			}

			.spec {
				font-size: 26upx;
				color: $font-color-light;
			}

			.price-box {
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 32upx;
				color: $font-color-dark;
				padding-top: 10upx;

				.price {
					margin-bottom: 4upx;
				}
				.number{
					font-size: 26upx;
					color: $font-color-base;
					margin-left: 20upx;
				}
			}

			.step-box {
				position: relative;
			}
		}
	}
	.yt-list {
		margin-top: 16upx;
		background: #fff;
	}

	.yt-list-cell {
		display: flex;
		align-items: center;
		padding: 10upx 30upx 10upx 40upx;
		line-height: 70upx;
		position: relative;

		&.cell-hover {
			background: #fafafa;
		}

		&.b-b:after {
			left: 30upx;
		}

		.cell-icon {
			height: 32upx;
			width: 32upx;
			font-size: 22upx;
			color: #fff;
			text-align: center;
			line-height: 32upx;
			background: #f85e52;
			border-radius: 4upx;
			margin-right: 12upx;

			&.hb {
				background: #ffaa0e;
			}

			&.lpk {
				background: #3ab54a;
			}

		}

		.cell-more {
			align-self: center;
			font-size: 24upx;
			color: $font-color-light;
			margin-left: 8upx;
			margin-right: -10upx;
		}

		.cell-tit {
			flex: 1;
			font-size: 26upx;
			color: $font-color-light;
			margin-right: 10upx;
		}

		.cell-tip {
			font-size: 26upx;
			color: $font-color-dark;

			&.disabled {
				color: $font-color-light;
			}

			&.active {
				color: $base-color;
			}
			&.red{
				color: $base-color;
			}
		}

		&.desc-cell {
			.cell-tit {
				max-width: 90upx;
			}
		}

		.desc {
			flex: 2;
			font-size: $font-base;
			color: $font-color-dark;
			text-align: right;
		}
	}
	
	.footer{
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 995;
		display: flex;
		align-items: center;
		width: 100%;
		height: 90upx;
		justify-content: space-between;
		font-size: 30upx;
		background-color: #fff;
		z-index: 998;
		color: $font-color-base;
		box-shadow: 0 -1px 5px rgba(0,0,0,.1);
		.price-content{
			padding-left: 30upx;
		}
		.price-tip{
			color: $base-color;
			margin-left: 8upx;
		}
		.price{
			font-size: 36upx;
			color: $base-color;
		}
		.submit{
			display:flex;
			align-items:center;
			justify-content: center;
			width: 280upx;
			height: 100%;
			color: #fff;
			font-size: 32upx;
			background-color: $base-color;
		}
		button {
			border-radius: 0;
			margin: 0;
			padding: 0;
		}
	}
	
	/* 优惠券面板 */
	.mask{
		display: flex;
		align-items: flex-end;
		position: fixed;
		left: 0;
		top: var(--window-top);
		bottom: 0;
		width: 100%;
		background: rgba(0,0,0,0);
		z-index: 9995;
		transition: .3s;
		
		.mask-content{
			width: 100%;
			min-height: 30vh;
			max-height: 90vh;
			background: #f3f3f3;
			transform: translateY(100%);
			transition: .3s;
			overflow-y:scroll;
		}
		&.none{
			display: none;
		}
		&.show{
			background: rgba(0,0,0,.4);
			
			.mask-content{
				transform: translateY(0);
			}
		}
	}

	/* 优惠券列表 */
	.coupon-item{
		display: flex;
		flex-direction: column;
		margin: 20upx 24upx;
		background: #fff;
		.con{
			display: flex;
			align-items: center;
			position: relative;
			height: 120upx;
			padding: 0 30upx;
			&:after{
				position: absolute;
				left: 0;
				bottom: 0;
				content: '';
				width: 100%;
				height: 0;
				border-bottom: 1px dashed #f3f3f3;
				transform: scaleY(50%);
			}
		}
		.left{
			display: flex;
			flex-direction: column;
			justify-content: center;
			flex: 1;
			overflow: hidden;
			height: 100upx;
		}
		.title{
			font-size: 32upx;
			color: $font-color-dark;
			margin-bottom: 10upx;
		}
		.time{
			font-size: 24upx;
			color: $font-color-light;
		}
		.right{
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			font-size: 26upx;
			color: $font-color-base;
			height: 100upx;
		}
		.price{
			font-size: 44upx;
			color: $base-color;
			&:before{
				content: '￥';
				font-size: 34upx;
			}
		}
		.tips{
			font-size: 24upx;
			color: $font-color-light;
			line-height: 60upx;
			padding-left: 30upx;
		}
		.circle{
			position: absolute;
			left: -6upx;
			bottom: -10upx;
			z-index: 10;
			width: 20upx;
			height: 20upx;
			background: #f3f3f3;
			border-radius: 100px;
			&.r{
				left: auto;
				right: -6upx;
			}
		}
	}
	
	.delivery-section {
		display: flex;
		flex-direction: row;
		align-items: center;
		background-color: #fff;
		padding: 20upx 30upx;
		
		view {
			border-radius: 100upx;
			margin-right: 10upx;
			padding: 10upx;
		}
		
		.active {
			color: #fff;
			background-color: $primary-color;
		}
		
		text {
			position: absolute;
			right: 30upx;
			color: $primary-color;
		}
	}
	
	.delivery-desc {
		background-color: #fff;
		margin-top: 20upx;
		padding: 30upx;
		
		view {
			margin-bottom: 20upx;
		}
	}
</style>
